package org.hackystat.devcathlon.ui.page.matches.invitations;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.hackystat.devcathlon.configuration.ConfigurationException;
import org.hackystat.devcathlon.engine.test.DevcathlonTestHelper;
import org.hackystat.devcathlon.ui.DevcathlonApplication;
import org.hackystat.devcathlon.ui.page.login.LoginPage;
import org.junit.Test;

/**
 * Test Matches Invitation Page.
 * @author Ka Hung Phillip Lau
 *
 */
public class TestInvitationPage extends DevcathlonTestHelper {

  /**
   * Test InvitationsPage.
   * 
   * @throws ConfigurationException Unexpected error. 
   */
  @Test
  public void testLoginInvitationsPage() throws ConfigurationException {
    WicketTester tester = new WicketTester(new DevcathlonApplication());
    tester.startPage(InvitationsPage.class);
    tester.assertRenderedPage(LoginPage.class);
    
    FormTester formTester = tester.newFormTester("loginForm");
    formTester.setValue("user", "admin@hackystat.org");
    formTester.setValue("password", "admin@hackystat.org");
    formTester.submit();
    
    tester.assertRenderedPage(InvitationsPage.class);
 
    assertNull("wicket ID form found.", tester.getTagByWicketId("matchdetails"));

    assertNull("wicket ID form not found.", tester.getTagByWicketId("InvitationsForm"));
    assertNotNull("wicket ID form found.", tester.getTagByWicketId("InviteForm"));
  }

}
